//
//  BaseTableViewController.m
//  微博
//
//  Created by 沈艳男 on 15/10/29.
//  Copyright © 2015年 沈艳男. All rights reserved.
//

#import "BaseTableViewController.h"
#import "VistorLoginView.h"
#import "OAuthController.h"
#import "UserAccount.h"

@interface BaseTableViewController () <VistorLoginViewDelegate>
@property (nonatomic, assign,) BOOL isLogin;

@end

@implementation BaseTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)loadView
{
    UserAccount *userAccount = [UserAccount sharedUserAccount];
    self.isLogin = [userAccount userLogon];
    self.isLogin ? [super loadView] : [self setUpVistroView];
}

- (void)setUpVistroView
{
    VistorLoginView *vistor = [VistorLoginView new];
    // 设置代理
    vistor.delegate = self;
    self.view = vistor;
    self.vistorLoginView = vistor;
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"注册" style:UIBarButtonItemStylePlain target:self action:@selector(btnClickRegister)];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"登录" style:UIBarButtonItemStylePlain target:self action:@selector(btnClickLogin)];
}

#pragma mark - 实现注册登陆点击的代理方法
- (void)btnClickLogin
{
    OAuthController *oc = [OAuthController new];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:oc];
    [self presentViewController:nav animated:YES completion:nil];
}

- (void)btnClickRegister
{

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Incomplete implementation, return the number of sections
    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete implementation, return the number of rows
    return 0;
}



@end
